<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="../baselayout/import.jsp"%>
<%@ taglib uri="http://www.bjtu.edu.cn/taglibs" prefix="wt" %>  
<style>
.tfidf form{
	text-align:center;
	height:100%;
	position:relative;
	width:100%;
}
.tfidf #text{
	display:block;
	width:100%;
	height:400px;
	text-shadow:2px 2px rgba(128,128,128,0.3);
	box-shadow:10px 10px 20px rgba(128,128,128,0.5);
		-moz-box-shadow:10px 10px 20px rgba(128,128,128,0.5);
	-webkit-box-shadow:10px 10px 20px rgba(128,128,128,0.5);
	-ms-box-shadow:10px 10px 20px rgba(128,128,128,0.5);
	font-size:1.5em;
}
.tfidf input[type=submit]{
	width:100px;
	margin:30px auto;
	text-shadow:2px 2px rgba(128,128,128,0.3);
	box-shadow:10px 10px 20px rgba(128,128,128,0.5);
	-moz-box-shadow:10px 10px 20px rgba(128,128,128,0.5);
	-webkit-box-shadow:10px 10px 20px rgba(128,128,128,0.5);
	-ms-box-shadow:10px 10px 20px rgba(128,128,128,0.5);
}
.tfidf .header{
	position:relative;
}
.tfidf .header > a{
	position:absolute;
	right:20px;
	top:0;
}
.tfidf .header .tip a{
	margin:10px 10px;
}
.tfidf .tfidf-tr button{
	margin: 0 10px;
}
</style>
<div class="tfidf">
	<div class="page-header">
	  <h1>TFIDF 模型 </h1>
	</div>
	<div class="panel panel-primary">
	<div class="panel-body">
		<c:choose>
		       <c:when test="${isExist}">
		           	<div class="header ">
						<h1 >输入待转换成文本向量的自然文本</h1>
						<div class="tip">
	  						<a class="btn btn-success" href="${staticPath}/fp/download.do?filename=feature.txt">下载feature</a>
	  						<a class="btn btn-success" href="${staticPath}/fp/download.do?filename=label.txt">下载label</a>
	  						<a class="btn btn-success" href="${staticPath}/fp/download.do?filename=vectors.txt">下载vectors</a>
						</div>
					</div>
					<form action="${staticPath}/admin/task/dotask.do" method="post" target="_blank">
						<input type="hidden" name="command_type" value="command_type_tfidf_trans">
						<textarea id="text" name = "command_text_trans" ></textarea>
						<input class="button button-primary" type="submit" value="提交">
					</form>
					<div class="panel panel-primary">
					      <div class="panel-heading">
					        <h3 class="panel-title">文件批量转换</h3>
					      </div>
					      <div class="panel-body">
					        <form id="upload" method="post" action="./trans.do" enctype="multipart/form-data" target="_blank">
					        	<button class="btn btn-primary" type="button" onclick="upload(this)" >选择文件文本文件</button>
					        	<div>
					        		<label id="fn"></label>
					        		<input id="file" style="display:none" type="file" name="file" onchange="change(this)">
					        	</div>
					        	<input type="submit"  class="btn btn-info" value="提交">        
					        </form>
					      </div>
					</div>
		       </c:when>
		       <c:otherwise>
		     		<div class="header">
						<h1>模型不存在</h1>
						<h2>${tip }</h2>
					</div>
					<button type="button" id='buildTFIDF' class="btn no-bg btn-contact">建立TFIDF模型</button>
		       </c:otherwise>
		</c:choose>
	</div>
 </div>
</div>
 <script>
  $(document).ready(function(){
	  !function(){
	 		var btnid = '#buildTFIDF';
	 		var command =  'command_type_tfidf';
	 	 	function buildTFIDF(command){
	 	 		$.ajax({
		 	 			url:"/wechat/admin/task/dotask.do",
		 	 			type:'post',
		 	 			data:{'command_type':command},
		 	 			success:function(data){
		 	 				$("#main").html(data);
		 	 			},
		 	 			error:function(err){
		 	 				console.log(err);
		 	 			}
	 	 			});
	 	 	}
	 		!function(param){
	 			$('#buildTFIDF').click(function(){
	 				buildTFIDF(param);
	 			});
	 		}(command);
	 		
	 	}();
		!function(w){
    		$('#myModal').on('hidden.bs.modal', function (e) {
    			div = e.currentTarget;
    			var value = $("#param",div).val().trim();
    			if(/c\d{1,2}$/.test(value)){
    				$.ajax({
    					url:"./handlefs.do",
    					type:'post',
    					data:{"action":"mkdir","arg":value},
    					success:function(data){alert(data)},
    					error:function(e){alert(e)}
    				})
    			}	
    		});
    		
    	}(window)
		
	});
 /* 
    function submitForm(){
    	$("#upload input[type=submit]").click();
    	$("#fileArea").css('display','none');
    }
    function del(btn){
    	var subdir = $(btn).parent().siblings(".lb").html().trim();
		if(/^c\d{1,2}$/.test(subdir)){
			$.ajax({
				url:"./handlefs.do",
				type:'post',
				data:{"action":"rmdir","arg":subdir},
				success:function(data){alert(data)},
				error:function(e){alert(e)}
			})
		}
    }
    function addNewClass(action){
		$('#myModal').modal('show');
	}
    function upload(btn){
		var subdir = $(btn).parent().siblings(".lb").html().trim();
		if(/^c\d{1,2}$/.test(subdir)){
			$("#upload input[name=subdir]").val(subdir);
			$("#upload input[type=file]").click();
		}else{
			return false;
		}
	}
	function change(btn){
		var file = $(btn).val();
		if(typeof file == 'string' && file.length>0){
			//$("#upload input[type=submit]").click();
			$("#fn").html(file);
			$("#fileArea").css('display','block');
		}
	} */
   
    </script>